package com.slfx.data.permission.controller;

import com.slfx.data.permission.entity.SystemProject;
import com.slfx.data.permission.service.SystemProjectService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: slfx
 * @Date: 2023-01-02
 * @Description:
 **/
@RestController
@RequestMapping("/systemProject")
public class SystemProjectController {

    @Resource
    private SystemProjectService systemProjectService;

    /**
     * 根据ID获取
     *
     * @param id
     * @return
     */
    @GetMapping("/getById")
    public SystemProject getById(@RequestParam("id") Long id) {
        SystemProject systemProject = systemProjectService.getById(id);
        return systemProject;
    }

    /**
     * 新增
     *
     * @param systemProject
     * @return
     */
    @PostMapping("/save")
    public Long save(@RequestBody SystemProject systemProject) {
        systemProjectService.save(systemProject);
        return systemProject.getId();
    }


    /**
     * 数据来源：获取项目列表
     *
     * @return
     */
    @GetMapping("/list")
    public List<SystemProject> list() {
        List<SystemProject> list = systemProjectService.list(null);
        return list;
    }

}
